package com.yl.googleplayer_yl.holder;

import android.text.format.Formatter;
import android.view.View;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.yl.googleplayer_yl.R;
import com.yl.googleplayer_yl.bean.AppInfo;
import com.yl.googleplayer_yl.global.MyApp;
import com.yl.googleplayer_yl.utils.ApiService;
import com.yl.googleplayer_yl.utils.GlideUtil;

/**
 * Created by Administrator on 2016/11/1 0001.
 */

public class HomeHolder extends BaseHolder<AppInfo> {
    ImageView ivIcon;
    TextView tvName;
    RatingBar rbStar;
    TextView tvSize;
    TextView tvDes;

    @Override
    protected View initHolder() {
        convertView = View.inflate(MyApp.context, R.layout.adapter_home, null);
        ivIcon = (ImageView) convertView.findViewById(R.id.iv_icon);
        tvName = (TextView) convertView.findViewById(R.id.tv_name);
        rbStar = (RatingBar) convertView.findViewById(R.id.rb_star);
        tvSize = (TextView) convertView.findViewById(R.id.tv_size);
        tvDes = (TextView) convertView.findViewById(R.id.tv_des);
        return convertView;
    }

   // View convertView;


    @Override
    public void bindData(AppInfo appInfo) {
       /* Glide.with(MyApp.context).load(ApiService.IMAGE_PREFIX + appInfo.getIconUrl()).into(ivIcon);*/
        GlideUtil.setCircleImageUrl(ApiService.IMAGE_PREFIX + appInfo.getIconUrl(),ivIcon,40);
        rbStar.setRating(appInfo.getStars());
        tvDes.setText(appInfo.getDes());
        tvName.setText(appInfo.getName());
        tvSize.setText(Formatter.formatFileSize(MyApp.context, appInfo.getSize()));
    }


}
